<template>
  <div class="swriper">
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="(image) in images" :key="image.id">
       <a :href="image.url"> <img v-lazy="image.img" /></a>
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<style>
/* .van-swipe {
   height: 152px;
}
.van-swipe__track{
  height: 152px;
} */
.swriper{
  margin-top: 20px;
}
img {
  width: 100%;
  height: 140px;
  border-radius: 10px;
}
</style>

<script>
import { Food_tuijian } from "../api/index";
export default {
  name: "swriperView",
  data() {
    return {
      images: [
      
      ],
    };
  },
  created() {
    this.getTuijianFn();
  },
  methods: {
    async getTuijianFn() {
      await Food_tuijian().then((content) => {
        // console.log(content);
        let { state, result } = content;
        if (state == "success") {
          let { banner } = result;
          let objs = banner.map((item,index) => ({
            id: index,
            text: item.t,
            img: item.i,
            url: item.url,
          }));
          // console.log(objs);
          this.images=objs
        }
      });
    },
  },
};
</script>